// ====================变量定义======================
/**@type {HTMLVideoElement} */
var message = document.getElementById('message');
var messageTxt = document.getElementById('messageTxt');
var btn = document.getElementById('btn');
/**切换到留言板的按钮 */
const $message_button = document.getElementById("message_button");

// ================Start================
message.style.visibility = "hidden";
messageTxt.style.visibility = "hidden";
btn.style.visibility = "hidden";

var ul = document.createElement('ul'); //创建ul标签
message.appendChild(ul);


// ------------响应函数----------

$message_button.onclick = function () {
    $app.style.visibility = "hidden";
    $video.pause();
    $div_video.style.visibility = "hidden";
    message.style.visibility = "visible";
    messageTxt.style.visibility = "visible";
    btn.style.visibility = "visible";
}



btn.onclick = function () {
    var txt = messageTxt.value; //此时不能用$('plTxt').innerHTML,成对的标签使用innerHTNL,获得里面文字;
    if (txt.length == 0) { //判断输入为空的情况；
        alert('不能发表为空的评论');
    } else {
        var li = document.createElement('li'); //创建li标签
        ul.appendChild(li); // li添加为ul的子标签
        txt = txt + "<a href='javascript:void(0)'>删除</a>" + "<span class='time'>" + new Date().toLocaleTimeString() + "</span>";
        li.innerHTML = txt; //将文本赋给li标签中显示
        var dels = document.getElementsByTagName('a'); //获取所有标签a的id存到数组中
        for (var j = 0; j < dels.length; j++) {
            dels[j].onclick = function () { //将所有a标签设置点击事件
                //删除当前评论，就是删除当前“删除”所在超链接的li
                ul.removeChild(this.parentNode);
            }
        }
    }
    messageTxt.value = '';
}